<!-- /*
 * @Author: 俞明月
 * @Date:   2022-01-30
 * @Last Modified by:   俞明月
 * @Last Modified time: 2022-01-30
 */ -->
<template>
	<div class="ui-mode-container ui-mode-box flex-col">
        <div class="ui-header-item gradient">
            <div class="ui-header-arraw prev" @touchstart.stop @click="handleHistory">
                <i class="iconfont icon iconjiantou-zuo-cuxiantiao"></i>
            </div>
            <div class="ui-header-title">切换门店</div>
            <div class="ui-header-arraw next flex-row align-center" @touchstart.stop @click="handleHome">
                <i class="iconfont icon iconi-home"></i>
            </div>
        </div>
        <div class="ui-mode-content flex1 flex-col" ref="scrollPage">
            <template>
                <inner-agents ref="goods"></inner-agents>
            </template>
        </div>
    </div>
</template>
<script>
import mixinCommon from '@/views/content/mixins/common';
import mixinRequest from '@/views/content/mixins/request';
import innerAgents from './content';
export default {
    name: 'home/agent',
    data() {
        return {
            public_agent_info:{},
            public_user_info:{},
            user_addr_list:[]
        }
    },
    mixins:[
        mixinCommon,
        mixinRequest
    ],
    components:{
        innerAgents
    },
    computed:{
    },
    watch:{
        resourceLoaded:{
            handler(flag){
                flag&&this.$nextTick(this.init); 
            },
            immediate:true
        }
    },
    created(){
    },
    mounted(){
    },
    methods:{
        // 初始化
        init(){
            var addr = this.$route.query.addr
            if(addr&&addr!="null"){
                this.$refs.goods.getUserID().then((result)=>{
                    console.log(result)
                    this.$refs.goods.sendlocation(result.id_public_user_info,this.$route.query.latng.split(',')[0],this.$route.query.latng.split(',')[1]).then(({result,response})=>{
                        this.$refs.goods.getListInfo({
                            flag:true,
                            page:0
                        });
                    }).catch(({msg})=>{
                        console.log(msg)
                        this.showMessage(msg,false);
                    });
                }).catch(({msg})=>{
                    this.showMessage(msg,false);
                });
            }else{
                this.$refs.goods.getListInfo({
                    flag:true,
                    page:0
                });
            }
        },
        // 请求失败刷新
        handleRefresh(){
            this.init();
        }
    },
    beforeDestroy(){
    }
}
</script>
<style lang="less" scoped>
.mt-address-head{
    padding: 0.5rem 0.5rem 0 0.5rem;
    background: #fff;
    margin-bottom: 0.5rem;
    position: relative;
    .mt-address-init{
        position: relative;
        p.m{
            line-height: 1rem;
            font-size: 0.7rem;
            padding: 0.1rem 0;
        }
        .mt-address-btn {
            position: absolute;
            right: 0;
            bottom: 0;
            display: block;
            height: 1.2rem;
            border-radius: 0.2rem;
            padding: 0 0.5rem;
            opacity: 0.9;
            font-size: 0.55rem;
            line-height: 1.2rem;
            color: #fff;
            cursor: pointer;
            text-align: center;
            background: #2398aa;
            &:before {
                content: '';
                display: none;
                bottom: -0.5rem;
                margin-bottom: -1px;
                left: 50%;
                margin-left: -6px;
                position: absolute;
                border: 6px solid transparent;
                border-bottom-color: #f3fef7;
                z-index: 2;
            }
            &.active::before{
                display:block;
            }
            &:after {
                content: '';
                display: none;
                bottom: -0.5rem;
                margin-bottom: -1px;
                left: 50%;
                margin-left: -7px;
                position: absolute;
                border: 7px solid transparent;
                border-bottom-color: #a8edc1;
                z-index: 1;
            }
            &.active::after{
                display:block;
            }
        }
        
    }
    .mt-address-box {
        position: relative;
        margin-bottom: -1px;
        z-index: 2;
        background: #f3fef7;
        padding: 0.3rem 0.5rem 0.5rem;
        border: solid 1px #caefd8;
        p{
            line-height: 1rem;
            font-size: 0.7rem;
            padding: 0.1rem 0;
            &.tip {
                font-size: 0.6rem;
                line-height: 1rem;
                color: #e5590b;
                position: relative;
                padding: 0.1rem 0 0.1rem 0.8rem;
                text-align: justify;
                text-justify: inter-ideograph;
            }
        }
    }
    .mt-address-button {
        border-top: solid 1px #f7f7f7;
        position: relative;
        height: 2.2rem;
        line-height: 2.2rem;
        font-size: 0.7rem;
        .button {
            position: absolute;
            right: 0;
            top: 0;
            .item {
                font-size: 0.7rem;
                margin-left: 1rem;
                color: #9b9b9b;
            }
        }
        
    }
}
.mt-address-bottom {
    box-shadow: 0 0 0.2rem #ddd;
    position: relative;
    z-index: 10;
    .mt-item-button {
        position: relative;
        display: block;
        opacity: 0.9;
        border-radius: 0.2rem;
        height: 2.2rem;
        line-height: 2.2rem;
        font-size: 0.8rem;
        color: #fff;
        cursor: pointer;
        text-align: center;
    }
}
</style>